<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <table border="1">
    <caption>个人信息</caption>
    <tr>
      <td>照片:</td><td><img :src="p.url" width="100"></td>
    </tr>
    <tr><td>名字:</td><td>{{p.name}}</td></tr>
    <tr><td>年龄:</td><td>{{p.age}}</td></tr>
    <tr><td>好友:</td>
      <td><ul>
          <li v-for="name in p.friends">{{name}}</li>
        </ul></td></tr>
  </table>
  <input type="button" value="加载数据" @click="f()">
</div>
<script src="js/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      p:{name:"",age:"",url:"",friends:[]}
    },
    methods:{
      f(){
        //把从服务器请求的数据直接赋值给p对象,由于p对象和页面中的元素进行了绑定
        //当p对象的值发生改变时页面自动跟着发生改变
        v.p = {name:"传奇哥",age:18,url:"fcq.jpg",friends:["貂蝉","武则天","孙尚香"]};
      }
    }
  })
</script>
</body>
</html>